导航菜单
首页 >  Dynamic mbuf  > DPDK: lib/librte

DPDK: lib/librte

RTE Mbuf dynamic fields and flags

Many DPDK features require to store data inside the mbuf. As the room in mbuf structure is limited, it is not possible to have a field for each feature. Also, changing fields in the mbuf structure can break the API or ABI.

This module addresses this issue, by enabling the dynamic registration of fields or flags:

a dynamic field is a named area in the rte_mbuf structure, with a given size (>= 1 byte) and alignment constraint.a dynamic flag is a named bit in the rte_mbuf structure, stored in mbuf->ol_flags.

The placement of the field or flag can be automatic, in this case the zones that have the smallest size and alignment constraint are selected in priority. Else, a specific field offset or flag bit number can be requested through the API.

The typical use case is when a specific offload feature requires to register a dedicated offload field in the mbuf structure, and adding a static field or flag is not justified.

Example of use:

A rte_mbuf_dynfield structure is defined, containing the parameters of the dynamic field to be registered: const struct rte_mbuf_dynfield rte_dynfield_my_feature = { ... };The application initializes the PMD, and asks for this feature at port initialization by passing DEV_RX_OFFLOAD_MY_FEATURE in rxconf. This will make the PMD to register the field by calling rte_mbuf_dynfield_register(&rte_dynfield_my_feature). The PMD stores the returned offset.The application that uses the offload feature also registers the field to retrieve the same offset.When the PMD receives a packet, it can set the field: *RTE_MBUF_DYNFIELD(m, offset, ) = value;In the main loop, the application can retrieve the value with the same macro.

To avoid wasting space, the dynamic fields or flags must only be reserved on demand, when an application asks for the related feature.

The registration can be done at any moment, but it is not possible to unregister fields or flags for now.

A dynamic field can be reserved and used by an application only. It can for instance be a packet mark.

To avoid namespace collisions, the dynamic mbuf field or flag names have to be chosen with care. It is advised to use the same conventions than function names in dpdk:

"rte_mbuf_dynfield_" if defined in mbuf library"rte__dynfield_" if defined in another library"rte_net__dynfield_" if defined in a in PMDany name that does not start with "rte_" in an application

Definition in file rte_mbuf_dyn.h.

相关推荐: